from flask import Flask,render_template
import pandas as pd
import json

app = Flask(__name__,template_folder='./templates',static_folder="./templates/static")

@app.route('/')
def hello():
    df = pd.read_csv("./source/data.csv", sep=',',encoding='gbk')#读取表格
    da = df.to_dict('list')#形成字典
    keys = ','.join(da.keys())
    #'项目名称,在途需求,未纳入项目,测试,测试完毕,开发,系统设计,需求分析,已纳入项目,已交付'
    p = keys.split(',')
    #['项目名称', '在途需求', '未纳入项目', '测试', '测试完毕', '开发', '系统设计', '需求分析', '已纳入项目', '已交付']
    p0 = da["项目名称"]
    p1 = da["在途需求"]
    p2 = da["未纳入项目"]
    p3 = da["测试"]
    p4 = da["测试完毕"]
    p5 = da["开发"]
    p6 = da["系统设计"]
    p7 = da["需求分析"]
    p8 = da["已纳入项目"]
    p9 = da["已交付"]
    return render_template('template.html',data1=p[1:-1],data2=p0,data3=p1,data4=p2,data5=p3,
                           data6=p4,data7=p5,data8=p6,data9=p7,data10=p8,data11=p9,name1=p[1],
                           name2=p[2],name3=p[3],name4=p[4],name5=p[5],name6=p[6],name7=p[7],
                           name8=p[8],name9=p[9])#传入login网页{{}}对应的值


@app.route('/bar')
def bar():
    return render_template('bar-label-rotation.html')

@app.route('/menu')
def menu():
    with open('templates/menu.json', 'r',encoding='utf-8') as f:
        return json.load(f)


@app.route('/table')
def table():
    return render_template('index2.html')

@app.route('/can')
def can():
    return render_template('candlestick-sh.html')

@app.route('/pie')
def pie():
    return render_template('pie-custom.html')

@app.route('/wate')
def wate():
    return render_template('watermark.html')

@app.route('/mix')
def mix():
    return render_template('mix-timeline-finance.html')


if __name__ == "__main__":
    app.run(port=5002)
